#!/bin/bash
if [ $# -ne 3 ]
then
    echo "Usage: $0 [interval] [count] [filename]"
    exit 0
fi

DIR="/media/X00086663"
if [ ! -d "$DIR" ]
then
    echo "Process Aborted: USB mounted at \"$DIR\" not found!"
    exit 0
fi

mpstat $1 $2 > $3
cp -b $3 "$DIR/$3"
echo "Script Complete"
